const obj = {
  name: "yz",
  age: 18
}


const entries = Object.entries(obj)
console.log(entries);


// const newObj = {}
// for(const entry of entries) {
//   newObj[entry[0]] = entry[1]
// }


// ES10中新增Object.fromEntries
const newObj = Object.fromEntries(entries)
console.log(newObj);

// Object.fromEntries应用场景
const queryString = 'name=yz&height=1.78'
const queryParams = new URLSearchParams(queryString)

const paramObj = Object.fromEntries(queryParams)
console.log(paramObj);
